package stu.aistar.mapper;

import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.*;
import stu.aistar.model.pojo.Session;
import stu.aistar.model.vo.SessionVo;

import javax.persistence.criteria.CriteriaBuilder;
import java.util.List;

/**
 * @author Administrator
 */
@Mapper
public interface SessionMapper {
    @Select("select * from session where start > now()")
    List<Session> findAll();

    @Select("select * from session where start > now() and ciname_id " +
            "= #{cinameId} and hall_id = #{hallId} and movie_id = #{movieId} and status = 1 order by start asc")
    List<Session> findByCondition(Session session);


    @Insert("insert into session values(null,null,#{movieId},#{hallId},#{cinameId},#{start},#{end},1)")
    Integer insert(Session session);


    List<SessionVo> findAllSessions();

    @Update("update session set status = 0 where id = #{id}")
    Integer deleteSession(@Param("id") Integer sid);

    @Update("update session set hall_id = #{hid},movie_id = #{mid}, ciname_id =#{cid}" +
            ",start = #{start},end = #{end} where id =#{id}")
    Integer updateSession(SessionVo session);
}
